package com.hyzx.qbasic.admin.common.util;

import com.hyzx.qbasic.admin.model.enums.ResStatus;
import com.hyzx.qbasic.admin.model.vo.res.BaseResModel;

/**
 * Created by 黄江华 on 2018/5/15
 */

public class BaseResUtils {
    public static BaseResModel success() {
        BaseResModel baseResModel = new BaseResModel(ResStatus.Success, "操作成功", null);
        return baseResModel;
    }

    public static <T> BaseResModel<T> success(T response) {
        BaseResModel baseResModel = new BaseResModel(ResStatus.Success, "操作成功", response);
        return baseResModel;
    }

    public static BaseResModel serverError() {
        BaseResModel baseResModel = new BaseResModel(ResStatus.ServerError, "服务器发生错误，请检查服务器", null);
        return baseResModel;
    }

    public static BaseResModel paramError(String msg) {
        msg = "客户端请求错误:" + msg;
        BaseResModel baseResModel = new BaseResModel(ResStatus.ParameterError, msg, null);
        return baseResModel;
    }

    public static BaseResModel authorizationError() {
        BaseResModel baseResModel = new BaseResModel(ResStatus.AuthorizationError, "用户没有权限", null);
        return baseResModel;
    }

    public static BaseResModel forbiddenError() {
        BaseResModel baseResModel = new BaseResModel(ResStatus.ForbiddenError, "服务器拒绝请求", null);
        return baseResModel;
    }

    public static BaseResModel notFoundError() {
        BaseResModel baseResModel = new BaseResModel(ResStatus.NotFoundError, "服务器找不到请求的资源", null);
        return baseResModel;
    }
}
